#ifndef SPRITE_H
#define SPRITE_H
#include "../core/node_affiliate.h"
#include <string>
#include "../core/enum.h"

struct sprite_data
{
    SDL_Texture *texture = nullptr;
    SDL_FRect src = {0, 0, 0, 0};
    float angle = 0.0f;
    bool isFlip = false;
    sprite_data() = default;
    sprite_data(const std::string path);
};

class sprite :public node_affiliate{
protected:
    sprite_data data_;
    bool isFinished_ = false;
    glm::vec2 preScale_ = glm::vec2(1.0f);
public:
    virtual void render() override;
    sprite_data getData(){ return data_;};
    virtual void setData(const sprite_data& data);
    void setFlip(bool isFlip){data_.isFlip = isFlip;};
    void setAngle(float angle){data_.angle = angle;};
    bool getFlip(){return data_.isFlip;};
    float getAngle(){return data_.angle;};
    bool isFinished(){return isFinished_;}
    void setFinished(bool finished){isFinished_ = finished;};
    void setPreScale(glm::vec2 percent){preScale_ = percent;};
    glm::vec2& getPreScale(){return preScale_;};
    static sprite* createSprite(screen* parent,const char* path,
        float scale = 1.0f,Anchor anchro = Anchor::ANCHOR_CENTER);
};

#endif // SPRITE_H